import request from '@/utils/request'

// 学习redux异步数据流
export function fetchCnode(params = {}) {
  return request({
    url: '/topics',
    method: 'GET',
    params
  })
}

export function fetchLogin(data = {}) {
  return request({
    url: '/react/user/login',
    method: 'POST',
    data
  })
}

// 使用token获取用户信息，怎么传token？ (request.headers)
export function fetchUserInfo(params = {}) {
  return request({
    url: '/react/user/info',
    method: 'GET',
    params
  })
}

// 获取品类
export function fetchAllCate(params = {}) {
  return request({
    url: '/react/good/cates',
    method: 'GET',
    params
  })
}

// 获取商品列表
export function fetchGoodList(params = {}) {
  return request({
    url: '/react/good/list',
    method: 'GET',
    params
  })
}

// 商品添加与编辑
export function fetchGoodUpdate(data = {}) {
  return request({
    url: '/react/good/update',
    method: 'POST',
    data
  })
}

// 根据商品id获取商品详情
export function fetchGoodInfo(id) {
  return request({
    url: '/react/good/info',
    method: 'GET',
    params: { id }
  })
}

// 删除商品
export function fetchGoodDelete(ids) {
  return request({
    url: '/react/good/delete',
    method: 'POST',
    data: { ids }
  })
}